package Day01_Reflect;

import TestClass.Person;

import java.lang.reflect.Constructor;
import java.util.Iterator;

public class Demo03_Reflect {
    public static void main(String[] args) throws Exception {
        //Constructor
        Class cls = Person.class;
        /*Constructor[] cs = cls.getConstructors();
        for (Constructor c : cs
             ) {
            System.out.println(c);
        }*/
        //newInstance只能调用无参构造
        //Object person = cls.newInstance("罗宾宾",30);
        Constructor constructor = cls.getConstructor(String.class, int.class);
        Object person = constructor.newInstance("罗宾宾",30);
        System.out.println(person);
    }
}
